<div class="btn-group groups">
      <a href="__URL__" class="btn btn-success">返回部门列表</a>
</div>
<div class="btn-group groups">
      <span type="button" class="btn btn-danger">部门修改</span>
</div>
<div class="the-box no-border store-list">
	<form id="ExampleBootstrapValidationForm" method="post" action="__URL__/uptAct" class="form-horizontal" enctype="multipart/form-data">
		<input name="department_id" type="hidden" value="{$department.department_id}" />
		<div class="form-group">
            <label class="col-lg-3 control-label">部门名称 <span style="color:red">*</span></label>
            <div class="col-lg-5">
                 <input type="text" class="form-control need"  type="text" name="department_name" value="{$department.department_name}" />
            </div>
       </div>
       
       <div class="form-group">
            <label class="col-lg-3 control-label">部门负责人 <span style="color:red">*</span></label>
            <div class="col-lg-5">
                 <input type="text" class="form-control need"  type="text" name="leader_id" value="{$department.leader_id}" onclick="open_choose_audience()" />
            </div>
       </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">人事负责人 <span style="color:red">*</span></label>
            <div class="col-lg-5">
                <input type="text" class="form-control need"  type="text" name="personnel" value="{$department.personnel}" onclick="open_choose_audience_checkbox()" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label"> 隶属部门 <span style="color:red">*</span></label>
            <div class="col-lg-5">
                <select class="form-control" tabindex="2" name="department_pid">
                    <option class="option" value="0" >根部门</option>
                    <foreach name="departments" item="value">
                        <option class="option" value="{$value.department_id}">{$value.department_name}</option>
                    </foreach>
                </select>
            </div>
        </div>

           <div class="form-group">
              <label class="col-lg-3 control-label">所在城市 <span style="color:red">*</span></label>
              <div class="col-lg-5">
                <select class="form-control" tabindex="2" name="local_id" id="{$department.local_id}">
                  <foreach name="city" item="value">
                    <option class="option" value="{$value.local_id}">{$value.local_name}</option>
                  </foreach>                            
                </select>
              </div>                  
           </div>  

           <div class="form-group">
              <label class="col-lg-3 control-label">楼名 <span style="color:red">*</span></label>
              <div class="col-lg-5">                      
                <select class="form-control" tabindex="2" name="building_id" id="{$department.building_id}">
                  <foreach name="build" item="value">
                    <option class="option" value="{$value.building_id}">{$value.building_name}</option>
                  </foreach>                            
                </select>               
              </div>
           </div>

           <div class="form-group">
              <label class="col-lg-3 control-label">部门楼层 <span style="color:red">*</span></label>
              <div class="col-lg-5">
                <select class="form-control" tabindex="2" name="floor_id" id="{$department.floor_id}">
                  <foreach name="floor" item="value">
                    <option class="option" value="{$value.floor_id}">{$value.floor_name}</option>
                  </foreach>                            
                </select>                
              </div>
           </div>
		<div class="form-group">
               <div class="col-lg-9 col-lg-offset-3">                                  
                   <input class="btn btn-primary button" id="submit"  type="submit" value="修改" />
               </div>
           </div>
	</form>	
</div>
<script type="text/javascript">
$('[name="department_pid"]').val('{$department.department_pid}');

var option  = document.getElementsByClassName("option");
for(var i=0;i<option.length;i++){
	if(option[i].value==option[i].parentNode.getAttribute("id")){
	  option[i].setAttribute("selected","selected");
	}
}
var roomcheck = document.getElementsByClassName("roomcheck");
	for(var j=0;j<roomcheck.length;j++){      
	if(roomcheck[j].getAttribute('id')==1){       
	  roomcheck[j].setAttribute("checked","true");
	}
}
var len = $('.need').length;
$("#submit").click(function(){
  for(var i=0;i<len;i++){
	  if($(".need:eq("+i+")").val()==""){
		  $(".need:eq("+i+")").css({border:"2px solid red"});
		  return false;
	  }
  }
});

$(".need").focus(function(){
	$(this).css({border:"2px solid #89F2D8"});
});
$(".need").blur(function(){
	$(this).css({border:""});
});
	  
function open_choose_audience(){
	var iWidth=320; //窗口宽度
	var iHeight=480;//窗口高度
	var iTop=(window.screen.height-iHeight)/2;
	var iLeft=(window.screen.width-iWidth)/2;
	window.open("__APP__/Audience/choose_audience?action=leader_id","res","Toolbar=no,Location=no,Direction=no,Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft);	
}
function open_choose_audience_checkbox(){
    var iWidth=320; //窗口宽度
    var iHeight=480;//窗口高度
    var iTop=(window.screen.height-iHeight)/2;
    var iLeft=(window.screen.width-iWidth)/2;
    window.open("__APP__/Audience/choose_audience_checkbox?action=personnel","res","Toolbar=no,Location=no,Direction=no,Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft);
}

</script>
